from flask import Blueprint, request, jsonify
from app.services.review_plan_service import ReviewPlanService

bp = Blueprint('review_plan', __name__)

@bp.route('/generate', methods=['POST'])
def generate_review_plan():
    """生成复习计划"""
    data = request.get_json()
    result = ReviewPlanService.generate_review_plan(
        record_id=data.get('record_id')
    )
    return jsonify(result), result['code']

@bp.route('/<int:student_id>', methods=['GET'])
def get_review_plan(student_id):
    """获取复习计划"""
    result = ReviewPlanService.get_review_plan(student_id)
    return jsonify(result), result['code']

# 根据复习id，删除复习计划
@bp.route('/<int:plan_id>', methods=['DELETE'])
def delete_review_plan(plan_id):
    result = ReviewPlanService.delete_review_plan(plan_id)
    return jsonify(result), result['code']